<?php

class Content_Controller_Admin_Post extends Controller
{

    public function actionIndex($request, $response)
    {
        $table = Agis::getTable('content@post');

        $select = $table -> select();

        $paging = $this -> paging = Zend_Paginator::factory($select);

        $paging -> setCurrentPageNumber($request -> getParam('page', 1));

    }

    public function actionAdd($request, $response)
    {

        $table = Agis::getTable('content@post');

        $response -> form = $form = new Content_Form_Admin_Post_Add;

        if ($request -> isGet())
        {
            return;
        }

        if ($request -> isPost() && $form -> isValid($_POST))
        {
            $values = $form -> getValues();

            $values['owner'] = Agis::getViewer() -> getId();

            $values['creation_date'] = date('Y-m-d H:i:s');

            $values['modification_date'] = date('Y-m-d H:i:s');

            $values['id'] = Agis::UUID('content@post');

            $row = $table -> fetchNew();

            $row -> setFromArray($values);

            $row -> save();

            $row -> updateAlias();

            $this -> redirect('admin/content/post');
        }
    }

}
